<?php

/**
 * userService类
 * @author meitu
 */
class userService extends commonService {

    /**
     *
     * @var userDao
     */
    protected $pao;

    public function __construct() {
        parent::__construct();
        $this->pao = InitPHP::getDao("user");
    }

    /**
     *  根据email获取用户信息
     * @param unknown $email            
     * @return Ambigous <boolean, multitype:>
     */
    public function getByEmail($email) {
        return $this->pao->getOneByField(array(
            'email' => $email
        ));
    }

    /**
     * 获取用户组的数组
     *
     * @return multitype:Ambigous <>
     */
    public function getUserTypeArray() {
        $dao = InitPHP::getDao("usertype");
        $result = unserialize($this->getCache()->get("usertype"));
        if ($result)
            return $result;
        else {
            $data = $dao->getAll();
            $result = array();
            foreach ($data as $k => $v) {
                $result[$v['id']] = $v['type_name'];
            }
            $this->getCache()->set("usertype", serialize($result));
            return $result;
        }
    }

    /**
     * 获取用户组的数组
     *
     * @return multitype:Ambigous <>
     */
    public function getUserType() {
        $dao = InitPHP::getDao("usertype");
        return $dao->getAll();
    }
}